package model

import "gorm.io/gorm"

type Slot struct {
	gorm.Model
	UserId     int    `gorm:"type:int" json:"userId"`
	CourseId   int    `gorm:"type:int" json:"courseId"`
	SlotTime   string `gorm:"type:varchar(30)" json:"slotTime"`
	SlotStatus int    `gorm:"type:int" json:"slotStatus"`
}

func (s *Slot) IsSlot(db *gorm.DB, userId int, courseId int, slotTime string) error {
	err := db.Where("user_id = ? and course_id = ? and slot_time = ?", userId, courseId, slotTime).First(&s).Error
	return err
}

func (s *Slot) AddSlot(db *gorm.DB) error {
	err := db.Create(&s).Error
	return err
}
